package com.solidumgame.martillo.score
{
	import com.pblabs.engine.PBE;
	import com.pblabs.engine.entity.PropertyReference;
	import com.pblabs.rendering2D.MovieClipRenderer;
	import com.solidumgame.martillo.score.events.ScoreGenericEvent;
	
	import flash.geom.Point;
	
	public class ScoreRendererComponent extends MovieClipRenderer
	{	

		protected var score:Scorer = new Scorer();
		public function ScoreRendererComponent()
		{
			super();
			this.clip = score;
			this.position = new Point(50,-150);
			this.size = new Point(280,68);
			this.scene = PBE.scene;
			this.layerIndex = 100;
		}
		
		override protected function onReset():void{
			super.onReset();
			owner.eventDispatcher.addEventListener(ScoreGenericEvent.SCORE_UPDATED_EVENT, scoreUpdated);

		}

		
		override protected function onRemove():void{
			super.onRemove();
			owner.eventDispatcher.removeEventListener(ScoreGenericEvent.SCORE_UPDATED_EVENT, scoreUpdated);
		}		
		
		protected function scoreUpdated(e:ScoreGenericEvent):void{
			score.updateScore(e.score);
		}
	}
}